package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.base.result.R;
import com.atguigu.srb.core.pojo.vo.BorrowInfoApprovalVO;
import com.atguigu.srb.core.pojo.vo.BorrowInfoVO;
import com.atguigu.srb.core.service.BorrowInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-01-04
 */
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowInfoController {
    @Resource
    BorrowInfoService borrowInfoService;
    @ApiOperation("借款审批")
    @PostMapping("approval")
    public R approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO){//自定义vo接收前端对话框审批数据
       borrowInfoService.approval(borrowInfoApprovalVO);
        return R.ok();
    }
    @ApiOperation("查询借款详情")
    @GetMapping("{id}")
    public R getBorrowInfo(@PathVariable("id")String id){
        //业务执行时需要返回两个VO类对象
        Map<String,Object> map =  borrowInfoService.getBorrowInfo(id);
        return R.ok().data("items" ,map );
    }
    @ApiOperation("借款列表")
    @GetMapping
    public R getBorrowInfos(){
        List<BorrowInfoVO> borrowInfoVOS =  borrowInfoService.getBorrowInfos();
        return R.ok().data("items" ,borrowInfoVOS );
    }
}

